import request from '@/utils/request';

export async function getPageContent(cate_id) {
    return request({
        url: '/api/v1/backend/content/page/' + cate_id,
        method: 'get'
    });
}

export async function updatePage(data) {
    return request({
        url: '/api/v1/backend/content/page',
        method: 'post',
        data
    });
}

export async function getCategoryTree() {
    return request({
        url: '/api/v1/backend/content/category/tree',
        method: 'get'
    });
}

export async function getNewsList(data) {
    return request({
        url: `/api/v1/backend/content/news/list/${data.cate_id}`,
        method: 'get',
        data
    });
}

export async function createNews(data) {
    return request({
        url: '/api/v1/backend/content/news',
        method: 'post',
        data
    });
}

export async function updateNews(data) {
    return request({
        url: '/api/v1/backend/content/news',
        method: 'put',
        data
    });
}

export async function deleteNews(id) {
    return request({
        url: '/api/v1/backend/content/news/' + id,
        method: 'delete'
    });
}

export async function getProductList(data) {
    return request({
        url: `/api/v1/backend/content/product/list/${data.cate_id}`,
        method: 'get',
        data
    });
}

export async function createProduct(data) {
    return request({
        url: '/api/v1/backend/content/product',
        method: 'post',
        data
    });
}

export async function updateProduct(data) {
    return request({
        url: '/api/v1/backend/content/product',
        method: 'put',
        data
    });
}

export async function deleteProduct(id) {
    return request({
        url: '/api/v1/backend/content/product/' + id,
        method: 'delete'
    });
}
